package com.example.langchaindemo.config;

import com.example.langchaindemo.Const.APIConst;
import dev.langchain4j.community.model.dashscope.QwenChatModel;
import dev.langchain4j.community.model.dashscope.QwenEmbeddingModel;
import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.embedding.EmbeddingModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class BeanConfig {
    /**
     * 阿里千问大模型
     *
     * @param properties
     * @return
     */
    @Bean
    public ChatLanguageModel chatLanguageModel(Langchain4jProperties properties) {
        return QwenChatModel.builder()
                .apiKey(APIConst.instance.QWEN_API_KEY())
                .modelName(APIConst.instance.QWEN_MODEL())
                .build();
    }

    /**
     * 阿里千问大模型
     * @param properties
     * @return
     */
    @Bean
    public EmbeddingModel embeddingModel(Langchain4jProperties properties) {
        return QwenEmbeddingModel.builder()
                .apiKey(APIConst.instance.QWEN_API_KEY())
                .modelName(APIConst.instance.QWEN_EMBEDDING_MODEL())
                .build();
    }
}
